<template>
	<view class="container">
		<scroll-view scroll-y class="questions-list" @scrolltolower="loadMore">
			<view class="titles"> 
				<view class="solt"> </view>
				<view class="t"> 我的收藏 </view>
			</view>
			<view v-if="paperList.length>0" style="padding-bottom: 40rpx;">
				<view class="list" v-for="(item, index) in paperList" :key="item.id" hover-class="bg-click" @click="answer(item)">
					<view class="contents">
						<view class="paper-header">
							<text class="title">{{item.question_title}}</text>
						</view>
						<view class="right">
							<image src="/static/rights.png" class="rights" mode=""></image>
						</view>
					</view>
					<view class="bottom-line">  </view>
				</view>
			</view>
			<view v-else class="nodata">暂无数据</view>
			<!-- 加载状态 -->
			<view class="loading-status">
				<text v-if="isLoading" class="loading-text">加载中...</text>
				<text v-if="!noMore" class="no-more">没有更多了~</text>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseURL: getApp().globalData.baseUrl,
				appid: uni.getStorageSync('appid'),
				paperList: [],
				currentPage: 1,
				noMore: false,
				isLoading: false,
				total: 0,
			}
		},
		onShow(){
			this.getList()
		},
		methods: {
			getList(){
				uni.request({
					url: this.baseURL + '/api/paper/myCollect',
					method: 'GET',
					data: {appid:this.appid,page:this.currentPage},
					header: { 'Content-Type': 'application/json' },
					success: (res) => {
						this.total  = res.data.data.total
						if( res.data.status == 100 ){
							this.searchShow =  false
							if (this.currentPage === 1) {
								this.paperList = res.data.data.data
							} else {
								this.paperList = [...this.paperList, ...res.data.data.data]
							}
							this.isLoading = false
							if( this.currentPage <= res.data.data.last_page ){
								this.noMore = false
							} else {
								this.noMore = true
							}
						}
					},
					fail: (err) => {
						console.error('请求失败:', err);
					}
				})
			},
			answer(item){
				uni.setStorageSync('timu',item)
				uni.navigateTo({url: '/pages/question/answer_ti'})
			}
		}
	}
</script>

<style>
	.container {height: 100vh;width: 100%;background: #f2f2f2;}
	.questions-list{height: 100%;margin: 0rpx auto;}
	.titles{padding: 20rpx 30rpx;display: flex;flex-direction: row;align-items: center;background: #fff;}
	.solt{width: 15rpx;height: 15rpx;background: #BEBEBE;}
	.titles .t{margin-left: 10rpx;font-size: 30rpx;font-weight: bold;}
	.list{background: #fff;}
	.contents{width: 90%;margin: 0 auto;display: flex;flex-direction: row;padding: 20rpx;border-bottom: 1rpx solid #BEBEBE;}
	.right{width: 20rpx;height: 30rpx;}
	.right .rights{width: 20rpx;height: 30rpx;}
	.paper-header{width: 100%;}
	.paper-header .title{font-size: 28rpx;color: #81A1BE;}
	.desc{display: flex;flex-direction: row;margin-top: 10rpx;}
	.paper-info .questions{font-size: 24rpx;color: #B9B9B9;}
	.paper-meta{margin-left: 20rpx;}
	.paper-meta .score{font-size: 24rpx;color: #B9B9B9;}
	.bg-click{background: #ebebeb;}
	.nodata{width: 100%;text-align: center;color: #999;padding-top: 50rpx;}
	.loading-status {text-align: center;padding: 30rpx 0;}
	.loading-text {color: #888;font-size: 28rpx;}
	.no-more {color: #ccc;font-size: 28rpx;}
	scroll-view ::-webkit-scrollbar {display: none;width: 0;height: 0;color: transparent;}
</style>
